#!/usr/bin/env python

import gtk
from mxit import handles
import gettext
gettext.install('blendIT','locale');

class signals:

   def __init__(self,blend):
      self.blend = blend;
      
   def on_response(self,widget,response,it):
      if response == gtk.RESPONSE_ACCEPT:
         group = str(it.entry.get_text());
         grps = self.blend.conn.roster._groups.keys();
         grps.append('BlendIT');
         grps.append('MXit Services'); # These are special groups

         if group in grps:
            self.blend.createErrorMessage(widget,
            _("The group, %s, already exists") % group);

            widget.run();
            return;
         else:
            # Create group
            groupObject = handles.Group(group);
            self.blend.conn.create_group(groupObject);
            self.blend.gui.buddyWindow.addGroup(groupObject);
            widget.destroy();
            if self.blend.autoAway:
               self.blend.autoAway.poke();
      else:
         widget.destroy();